package com.mach.platform.controller;

import com.mach.platform.domain.*;
import com.mach.platform.service.DMFConcentrationRecordServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("DMFConcentrationRecord")
public class DMFConcentrationRecordCtrl extends BaseCtrl<DMFConcentrationRecord> {

    @Autowired
    private DMFConcentrationRecordServiceImpl dmfConcentrationRecordService;

    @ApiOperation(value = "保存", notes = "接口备注：无", produces = "application/json")
    @PostMapping("/addParams")
    public Response add(@RequestBody List<DMFConcentrationRecord> dmfConcentrationRecords) {
        int result = 1;
        dmfConcentrationRecordService.add(dmfConcentrationRecords);
        return Response.ok(result);
    }

    @ApiOperation(value = "修改", notes = "接口备注：无", produces = "application/json")
    @PostMapping("/updateParams")
    public Response update(@RequestBody List<DMFConcentrationRecord> dmfConcentrationRecords) {
        int result = 1;
        dmfConcentrationRecordService.update(dmfConcentrationRecords);
        return Response.ok(result);
    }
    @Override
    public Response info(Long id) {
        return null;
    }

    /**
     * 分页查询
     * @param pageable
     * @param params
     * @return
     */
    @GetMapping("/findByPage")
    @Override
    public Response list(@PageableDefault(size = 50)Pageable pageable, @RequestParam Map params) {
        return Response.ok(dmfConcentrationRecordService.list(pageable, params));
    }

    /**
     * 根据时间查询数据
     * @param time
     * @return
     */
    @GetMapping("/getDayData")
    public Response list(String time){
        return Response.ok(dmfConcentrationRecordService.getProductionStateByTime(time));
    }

    @ApiOperation(value = "删除", notes = "接口备注：无", produces = "application/json")
    @DeleteMapping("/delete")
    @Override
    public Response delete(Long[] ids) {
        return Response.ok(dmfConcentrationRecordService.delete(ids));
    }

    @Override
    public Response save(DMFConcentrationRecord dmfConcentrationRecord) {
        return null;
    }

    @Override
    public Response update(DMFConcentrationRecord dmfConcentrationRecord) {
        return null;
    }

}
